# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html


class XiaohuaPipeline(object):
    def open_spider(self, spider):
        import csv
        self.csv_writer = csv.DictWriter(open("./girls.txt", "w"), fieldnames=("name", "image"))
        self.csv_writer.writeheader()

    def process_item(self, item, spider):
        self.csv_writer.writerow(item)
        return item

    def close_spider(self, spider):
        pass
